package com.leetcode.partition17;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/2/28 21:46
 */
public class LC1601最多可达成的换楼请求数目 {

    private static final int N = 25;
    private static int[] cnt = new int[N];
    private static int[][] edges;
    private static int n, m;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]);
        int[][] requests = new int[m][2];
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            requests[i] = new int[]{a, b};
        }
        writer.write(maximumRequests(n, requests) + "\n");
        writer.flush();
    }

    public static int maximumRequests(int _n, int[][] requests) {
        n = _n;
        m = requests.length;
        edges = requests;
        int ans = 0;
        for (int i = 0; i < 1 << m; i++) {
            if (Integer.bitCount(i) > ans && check(i)) ans = Integer.bitCount(i);
        }
        return ans;
    }

    private static boolean check(int s) {
        Arrays.fill(cnt, 0);
        for (int i = 0; i < m; i++) {
            int a = edges[i][0], b = edges[i][1];
            if ((s >> i & 1) == 1) {
                cnt[a]++;
                cnt[b]--;
            }
        }
        for (int i = 0; i < n; i++) {
            if (cnt[i] != 0) return false;
        }
        return true;
    }
}
